<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button onclick="save()">存cookie</button>
    <button onclick="read()">读cookie</button>

    <script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script>
    <script>

        console.log(Cookies);
        const username = '里斯';

        function save() {
            Cookies.set('username', username, { expires: new Date(Date.now() + 5000) });
        }

        function read() {
            console.log(Cookies.get('username'));
        }


    </script>
</body>
</html>